/** 路由规则文件 */
import { lazy } from "react"

import Login from '../views/Login'

// 配置路由规则
const routes = [
  {
    name: "r",
    path: "/",
    redirect: "/login",
    exact: true
  },
  {
    name: "login",
    path: "/login",
    component: Login,
    exact: false
  },
  {
    name: 'reg',
    path: '/reg',
    component: lazy(() => import('../views/Reg')),
    exact: false
  },
  {
    name: 'main',
    path: '/main',
    component: lazy(() => import('../views/Main')),
    children: [  // 类似vue，通过children配置二级路由
      {
        name: "r2",
        path: "/main",
        redirect: "/main/home",
        exact: true,
      },
      {
        name: 'home',
        path: '/main/home',
        component: lazy(() => import('../views/Home')),
        exact: false
      },
      {
        name: "brand",
        path: "/main/brand",
        component: lazy(() => import('../views/Brand')),
        exact: false
      },
      {
        name: 'cart',
        path: '/main/cart',
        component: lazy(() => import('../views/Cart')),
        exact: false
      },
      {
        name: 'ucenter',
        path: '/main/ucenter',
        component: lazy(() => import('../views/Ucenter')),
        exact: false
      },
    ]
  },
  {
    name: '404',
    path: '*',
    component: lazy(() => import('../views/NotFound')),
    exact: false
  },
]

export default routes